package net;

import java.io.File;

import java.io.FileWriter;
import java.io.IOException;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.util.PDFTextStripper;

/**
 * 
 * @author Noah Picard
 * Practice Code:
 * Testing converting PDF to Text and writing to a file.
 *
 */

public class PDFtoTxt {

	public static void main(String[] args) {
		System.out.println("Starting");
		
		try {
			//Opens PDF as an read/write document
			PDDocument pdd = PDDocument.load(new File("src/resources/testing.pdf"));
			
			//Opens PDFTextStripper to get text from p
			PDFTextStripper p = new PDFTextStripper();
			String text = p.getText(pdd);
			pdd.close();
			
			//Opens text document to write PDF text into
			FileWriter fw = new FileWriter("src/resources/testAsTxt.txt");
			fw.write(text);
			fw.close();
			
			System.out.println(text);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		System.out.println("Finished");
	}

}
